import { InputQuestion, QuestionBase, SelectQuestion, TextQuestion } from '@/components/public-template';
import { getMenNum } from '@/utils';
import { regExp } from '@/utils/regExp';

class IndexService {
  getQuestions(isShow) {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'code',
        label: '编码',
        value: null,
        disabled: true,
        hidden: isShow == 'ADD'
      }),
      new InputQuestion({
        key: 'name',
        label: '名称',
        required: true,
        prompt: '输入字符应在1-20之间',
        value: null,
        reg: regExp.len020,
        placeholder: '请输入'
      }),
      new SelectQuestion({
        key: 'type',
        label: '水印内容',
        required: true,
        prompt: '请选择',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_CONTENT',
          changeOptions: {
            1: [getMenNum('customizeContent', 'hidden', false)],
            2: [getMenNum('customizeContent', 'hidden', true)]
          }
        }
      }),
      new InputQuestion({
        key: 'customizeContent',
        label: '自定义内容',
        required: true,
        reg: regExp.len020,
        prompt: '不可为空，且字段长度不超过20',
        hidden: true,
        value: null
      }),
      new SelectQuestion({
        key: 'contentType',
        label: '类型',
        required: true,
        prompt: '请选择',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_TYPE'
        }
      }),
      new InputQuestion({
        key: 'transparency',
        label: '透明度',
        required: true,
        placeholder: '请选择',
        value: 100,
        type: 'number',
        reg: /^(?:[1-9][0-9]?|100)$/,
        prompt: '输入字符应在1-100之间'
      }),
      new InputQuestion({
        key: 'fontSize',
        label: '字体大小',
        type: 'number',
        required: true,
        prompt: '请输入',
        value: null
      }),
      new SelectQuestion({
        key: 'angle',
        label: '角度',
        required: true,
        prompt: '请选择',
        value: 4,
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_ANGLE'
        }
      }),
      new InputQuestion({
        key: 'acrossGap',
        label: '横向间距',
        type: 'number',
        required: true,
        prompt: '请输入',
        value: 100
      }),
      new InputQuestion({
        key: 'standGap',
        label: '纵向间距',
        type: 'number',
        required: true,
        prompt: '请输入',
        value: 100
      })
    ];
    return questions;
  }
  getViewQuestions() {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'code',
        label: '编码',
        value: null
      }),
      new TextQuestion({
        key: 'name',
        label: '名称',
        value: null
      }),
      new TextQuestion({
        key: 'type',
        label: '水印内容',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_CONTENT'
        }
      }),
      new TextQuestion({
        key: 'customizeContent',
        label: '自定义内容',
        value: null
      }),
      new TextQuestion({
        key: 'contentType',
        label: '类型',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_TYPE'
        }
      }),
      new TextQuestion({
        key: 'transparency',
        label: '透明度',
        value: null
      }),
      new TextQuestion({
        key: 'fontSize',
        label: '字体大小',
        value: null
      }),
      new TextQuestion({
        key: 'angle',
        label: '角度',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_ANGLE'
        }
      }),
      new TextQuestion({
        key: 'acrossGap',
        label: '横向间距',
        value: null
      }),
      new TextQuestion({
        key: 'standGap',
        label: '纵向间距',
        value: null
      })
    ];
    return questions;
  }
}

export default new IndexService();
